834A - The Useless Toy - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

x=['<','^','>','v']
s,e=input().split()
it=int(input())
for i in range(len(x)):
    if(x[i]==s):
        sp=i
for i in range(len(x)):
    if(x[i]==e):
        ep=i
if(((sp+it)%4)==((sp-it)%4)):
    print('undefined')
elif(x[((sp+it)%4)]==x[ep]):
    print('cw')
elif(x[((sp-it)%4)]==x[ep]):
    print('ccw')
else:
    print('undefined')
 			 	   			 		 	 		  	 	   	 	

C++ Code:

#include <bits/stdc++.h>

using namespace std;

int main()
{
    char a[2];
    int b[2];
    for (int i = 0; i < 2; i++)
    {
        cin >> a[i];
        if (a[i] == 'v')
            b[i] = a[i] - 117;
        if (a[i] == '<')
            b[i] = a[i] - 58;
        if (a[i] == '>')
            b[i] = a[i] - 58;
        if (a[i] == '^')
            b[i] = a[i] - 91;
    }

    int n;
    cin >> n;
    n = n % 4;
    if (n == 0 || n == 2)
    {
        cout << "undefined";
    }
    else
    {
        if (abs(b[0] - b[1]) % 2 == 0)
        {
            cout << "undefined";
        }
        else
        {
            if (b[1] > b[0] && b[1] - b[0] == n)
            {
                cout << "cw";
            }
            else if (b[1] > b[0] && b[1] - b[0] != n)
            {
                cout << "ccw";
            }
            else if (b[0] > b[1] && b[0] - b[1] == n)
            {
                cout << "ccw";
            }
            else if (b[0] > b[1] && b[0] - b[1] != n)
            {
                cout << "cw";
            }
        }
    }

    return 0;
}


Comments

Submit
0 Comments
More Questions

1391B - Fix You
988B - Substrings Sort
312A - Whose sentence is it
513A - Game
1711E - XOR Triangle
688A - Opponents
20C - Dijkstra
1627D - Not Adding
893B - Beautiful Divisors
864B - Polycarp and Letters
1088A - Ehab and another construction problem
1177B - Digits Sequence (Hard Edition)
1155B - Game with Telephone Numbers
1284A - New Year and Naming
863B - Kayaking
1395B - Boboniu Plays Chess
1475D - Cleaning the Phone
617B - Chocolate
1051B - Relatively Prime Pairs
95B - Lucky Numbers
1692D - The Clock
1553D - Backspace
1670D - Very Suspicious
1141B - Maximal Continuous Rest
1341A - Nastya and Rice
1133A - Middle of the Contest
385A - Bear and Raspberry
1311B - WeirdSort
1713F - Lost Array
236B - Easy Number Challenge